clear all
set more off
cd /Users/zimaoxiao/Dropbox/CC_Yield_Predict/replication_package/  // Navigate to replication folder on your own machine
global weather "gdd10_29 gdd29 prec prec2"

cap mkdir output

qui {				
use if inrange(year,1950,2000) using data/regression/reg_2020_prediction_gdd, clear
merge m:1 county_fips using data/yield/filter, keep(3) nogenerate

* column 1
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)

* column 2		
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend state_fips#c.trend2 [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)	
	
use if inrange(year,1950,2020) using data/regression/reg_2050_prediction_gdd, clear
merge m:1 county_fips using data/yield/filter, keep(3) nogenerate

* column 3
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)	

* column 4		
eststo: xi: reghdfe lncornyield $weather state_fips#c.trend state_fips#c.trend2 [aweight=corn_areaHarv], absorb(county_fips) vce(cluster county_fips StateXYear)	
		
noi esttab using output/TableS4.csv, keep($weather) ar2(%6.4f) scalar(N) compress star(* 0.1 ** 0.05 *** 0.01) b(%6.4f) se(%6.4f) nogaps noconstant replace						
}		
		
*** EOF
